{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>商户列表</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="collapse" id="searchBox">
                        <div class="layui-form layui-form-item">
                            <div class="layui-input-inline layui-form">
                                <select name="type" lay-search="">
                                    <option  value="">不限状态</option>
                                    <option value="1">正常</option>
                                    <option value="2">关闭</option>
                                </select>
                            </div>
                            <div class="layui-col-md6 layui-input-inline">
                                <input type="text" id="key" class="layui-input search" name="key" value="" placeholder="店铺名/手机号/地址"/>
                            </div>
                            <div class="layui-input-inline">
                                <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                                <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group pull-left" >
                        <a href="javascript:;" onclick="tableReload()" class="btn btn-success" data-toggle="tooltip" title="" data-original-title="刷新表格" data-placement="auto">
                            <i class="fa fa-refresh"></i>
                        </a>
                        <!--<a href="javascript:;" onclick="wk.layer_show('添加管理员','{:url('userAdd')}',900)">-->
                            <!--<button class="btn btn-primary" type="button">-->
                                <!--<i class="fa fa-plus"></i> 添加管理员-->
                            <!--</button>-->
                        <!--</a>-->
                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                            <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu animated fadeInDown" role="menu">-->
                            <!--<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>-->
                        <!--</ul>-->
                    </div>
                    <div class="input-group pull-right" data-toggle="tooltip" title="" data-original-title="搜索">
                        <button class="btn btn-primary" data-toggle="collapse"
                                data-target="#searchBox" >
                            <i class="glyphicon glyphicon-search"></i>
                        </button>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <ul onclick="view(this)" id="view_{{d.s_id}}">
                            <li><img data-original="{{d.s_thumb}}" src="{{d.s_thumb}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  /></li>
                        </ul>
                    </script>
                    <!--状态模板-->
                    <script type="text/html" id="staBar">
                        {{# if(d.s_status == 1){ }}
                            <span class="layui-badge layui-bg-green">正常</span>
                        {{# }else if(d.s_status == 2){ }}
                            <span class="layui-badge">关闭</span>
                        {{# } }}
                    </script>
                    <!--状态模板-->
                    <script type="text/html" id="adminBar">
                        <input type="hidden" id="zh{{d.s_id}}" value="{{d.status}}">
                        <input type="checkbox"  id="zt{{d.s_id}}" value="{{d.s_id}}"  lay-skin="switch"  lay-text="正常|关停" lay-filter="OnOff"{{ d.s_admin == 1 ? 'checked' : '' }}  >
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.href('{:url('driver')}?id={{d.s_id}}')" class="btn btn-primary btn-xs m-r-xs" title="商铺骑手"><i class="fa fa-motorcycle"></i></a>
                        <a href="javascript:;" onclick="wk.href('{:url('active')}?id={{d.s_id}}')" class="btn btn-primary btn-xs m-r-xs" title="商铺活动"><i class="fa fa-shopping-bag"></i></a>
                        <a href="javascript:;" onclick="wk.href('{:url('advertise')}?id={{d.s_id}}')" class="btn btn-primary btn-xs m-r-xs" title="商铺广告"><i class="fa fa-bullhorn"></i></a>
                        <a href="javascript:;" onclick="wk.href('{:url('shopType')}?id={{d.s_id}}')" class="btn btn-primary btn-xs m-r-xs" title="商铺分类"><i class="fa fa-bars"></i></a>
                        <a href="javascript:;" onclick="wk.layer_show('账户信息','{:url('account')}?id={{d.s_id}}')" class="btn btn-primary btn-xs m-r-xs" title="账户信息"><i class="fa fa-credit-card"></i></a>
                        <a href="javascript:;" onclick="wk.layer_show('商户信息','{:url('shopInfo')}?id={{d.s_id}}')" class="btn btn-primary btn-xs m-r-xs" title="商户信息"><i class="fa fa-newspaper-o"></i></a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Business/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , even: false //开启隔行背景
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            // ,width:100
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type:'numbers', width: 80, title: '序号'}
                , {field: 's_name', width: '', title: '商铺名称', align: 'center'}
                , {field: 's_thumb', width: 90, title: '商铺图片', align: 'center', templet: '#imgTpl'}
                , {field: 's_pinlei', width: '', title: '品类', align: 'center'}
                , {field: 's_phone', width: '', title: '手机号', align: 'center'}
                , {field: 's_address', width: '', title: '地址', align: 'center'}
                , {field: 's_integral', width: '', title: '积分', align: 'center'}
                , {field: 's_status', width: 100, title: '积分状态',align: 'center', templet: '#staBar'}
                , {fixed: 'right', width: 100, title: '状态',align: 'center', templet: '#adminBar'}
                , {fixed: 'right', width: 250, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $.each(res.data,function(index,item){
                    $('#view_'+item['s_id']).viewer({
                        url: 'data-original',
                    });
                });
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            // layer.tips(this.value + ' ' + this.name + '：'+ obj.elem.checked, obj.othis);
            if(obj.elem.checked == true){
                var num = 1;
            }else{
                var num = 2;
            }
            //用户状态
            wk.status(this.value,num, '{:url("businessState")}');
        });

        //批量操作
        var $ = layui.$, active = {
            getCheckData: function(){
                //批量删除
                wk.batchDel(getIds(),"{:url('batchDelUser')}");
            }
            ,forbiddenAll: function(){
                //批量禁用
                wk.batchForbidden(getIds(),2,"{:url('forbiddenAdmin')}");
            }
            ,usingAll: function(){
                //批量启用
                wk.usingAll(getIds(),1,"{:url('usingAdmin')}");
            }
            ,excelAll: function(){
                //导出Excel
                wk.excelAll(getIds(),$('#layuiForm').serialize(),"{:url('excelAdmin')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>